import React from "react";
import { Tabs } from "antd";
import Tab1 from "./reactforwarf";
import type { TabsProps } from "antd";

const App: React.FC = () => {
  const TabRef = React.useRef(null);
  const [activeKey, setActiveKey] = React.useState("1");
  const onChange = async (key: string) => {
    console.log(key, TabRef);
    //
    // TabRef.current?.onFinish();
    const res = await TabRef.current?.handleSubmit("edit");
    if (res) {
      setActiveKey(key);
    }
    console.log(res, "res");
  };

  return (
    <Tabs
      defaultActiveKey="1"
      items={[
        {
          key: "1",
          label: "Tab 1",
          children: <Tab1 ref={TabRef} />,
        },
        {
          key: "2",
          label: "Tab 2",
          children: "Content of Tab Pane 2",
        },
        {
          key: "3",
          label: "Tab 3",
          children: "Content of Tab Pane 3",
        },
      ]}
      activeKey={activeKey}
      onChange={onChange}
    />
  );
};

export default App;
